package me.zhengjie.modules.management.rest.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.management.domain.ConferenceRecord;
import me.zhengjie.modules.management.domain.MrRecordDtl;
import me.zhengjie.modules.management.domain.Pageable;
import me.zhengjie.modules.management.service.MrRecordDtlService;
import me.zhengjie.modules.management.service.dto.RoomCostCriteria;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * @program: eladmin
 * @description: 培训明细数据访问层
 * @author: ming.cao
 * @create: 2020-12-14 19:31
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "MR:培训明细管理")
@RequestMapping("/api/recordDtl")
public class MrRecordDtlController {
    private final MrRecordDtlService mrRecordDtlService;


    @GetMapping("/getListById")
    @Log("根据培训id获取明细")
    @ApiOperation("根据培训id获取明细")
    public Map<String,Object> getListById(Integer recordId, Pageable pageable){
      return mrRecordDtlService.getListById(recordId,pageable);
    }

    @PostMapping
    @Log("新增培训室明细")
    @ApiOperation("新增培训室明细")
    public void addMrRecordDtl(@RequestBody @Valid MrRecordDtl mrRecordDtl){
         mrRecordDtlService.addMrRecordDtl(mrRecordDtl);
    }

    @DeleteMapping
    @Log("删除培训室明细")
    @ApiOperation("删除培训室明细")
    public void delMrRecordDtl(@RequestBody List<Integer> ids){
        mrRecordDtlService.delMrRecordDtl(ids);
    }

    @PutMapping
    @Log("修改培训室明细")
    @ApiOperation("修改培训室明细")
    public void updateMrRecordDtl(@RequestBody MrRecordDtl mrRecordDtl){
        mrRecordDtlService.updateMrRecordDtl(mrRecordDtl);
    }

    @GetMapping("/roomCost")
    @Log("获取当前会议室费用")
    @ApiOperation("获取当前会议室费用（修改结束时间时）")
    public Map<String,Object> getCurrentRoomCost( RoomCostCriteria criteria){
        return mrRecordDtlService.getCurrentRoomCost(criteria);
    }


    @PostMapping("/settle")
    @Log("结算")
    @ApiOperation("结算")
    public void settle(@RequestBody ConferenceRecord record){
        mrRecordDtlService.settle(record);
    }
}
